<?php
require_once "../class/fenajax.class.php";
include "../dyn/connexion.php";

$f = newFen(__FILE__,"Liste des textes",1);

$f->displayHeader();

$id = $_SESSION['user_id'];

$res = mysql_query("SELECT * FROM PubliUserTexte WHERE idUser = ".$id.";");

if (mysql_num_rows($res) == 0) {
	echo "<div class=\"center\">
			".BMInfo("Note: Vous n'avez encore créer aucun texte",false)."<br /><br /><br />
		</div>
	";
}
else {
	echo "<table id=\"data un\" class=\"tab-tab\">
			<tr class=\"ui-tabs-nav ui-accordion ui-state-default tab-title\">
				<th>Auteur</th>
				<th>Titre</th>
				<th>Date</th>
				<th>Statut</th>
				<th>Modifier</th>
			</tr>
	";
	
	while($row = mysql_fetch_array($res)) {
		$res2 = mysql_query("SELECT * FROM Texte WHERE id = ".$row['idTexte']." ORDER BY titre;");
		
		while($row2 = mysql_fetch_array($res2)) {
			
			echo "<tr class=\"tab-data\" >
					<td>".$row2["auteur"]."</td> 
					<td>".$row2["titre"]."</td>
					<td>".$row2["date"]."</td>
			";
						
			if ($row2['statut'] == "0")		
				$nom_statut = "Non valider";
			
			if ($row2['statut'] == "1")		
				$nom_statut = "Privé";
				
			if ($row2['statut'] == "2")		
				$nom_statut = "Restreint";
				
			if ($row2['statut'] == "3")		
				$nom_statut = "Public";
				
			if ($row2['statut'] == "4")		
				$nom_statut = "Brouillon";

				
			
			echo "<td>".$nom_statut."</td>";
			
						
			echo "<td>
					<a href =\"#un\" onclick=\"formulaireUserTexteModif(event)\"><img id=\"".$row2['id']."\" src=\"../images/modifier.png\"  alt=\"Modifier\" title=\"Modifier ce texte\"/></a>
				</td>
			";
					
			
			echo "</tr>";

		}
	}
	
	echo "</table>";
}

$f->displayFooter();
?>